// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1
import "component/"

Rectangle {
    width: 480
    height: 480
    focus: true
    color: "#111111"

    signal playStart()
    signal exit()

    function pressed(key){
        switch(key){
        case Qt.Key_Up:
        case Qt.Key_Left:
            if(_list.currentIndex > 0){
                _list.currentIndex--;
            }
            break;
        case Qt.Key_Down:
        case Qt.Key_Right:
            if(_list.currentIndex < (_list.count - 1)){
                _list.currentIndex++;
            }
            break;

        case Qt.Key_Enter:
        case Qt.Key_Return:
        case Qt.Key_Space:
            exec(_list.currentIndex);
            break;
        default:
            break;
        }
        //console.debug("key");
    }
    function released(key){

    }

    function exec(index){
        switch(index){
        case 0:
            playStart();
            break;
        case 1:
            exit();
            break;
        default:
            break;
        }
    }

    Keys.onPressed: {
        pressed(event.key);
    }

    Image{
        anchors.fill: parent
        source: "./images/title_back.png"
    }

    Image{
        y: 30
        anchors.horizontalCenter: parent.horizontalCenter
        source: "./images/title_log.png"

    }

    ListModel{
        id: _model
        ListElement{
            //であいをやりなおす
            _message: "./images/title_list_1.png"
        }
        ListElement{
            //あきらめる
            _message: "./images/title_list_2.png"
        }
    }
    ListView{
        id: _list
        interactive: false
        anchors.horizontalCenter: parent.horizontalCenter
        width: 200
        height: 100
        y: parent.height * 3.5 / 5
        clip: true

        highlight: HighlightRect{
            list: _list
        }
        highlightFollowsCurrentItem: true
        highlightMoveDuration: 200

        model: _model
        delegate: Item{
            width: 200
            height: 30
            Image{
                anchors.centerIn: parent
                source: _message
            }
            MouseArea{
                anchors.fill: parent
                onClicked: {
                    exec(index);
                }
            }
        }
    }

}
